package com.hxc.web.controller.basicdata;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.basicdata.domain.TVillagerConditions;
import com.hxc.basicdata.service.ITVillagerConditionsService;
import com.hxc.common.utils.poi.ExcelUtil;
import com.hxc.common.core.page.TableDataInfo;

/**
 * 村情信息Controller
 * 
 * @author hxc
 * @date 2021-08-20
 */
@RestController
@RequestMapping("/basicdata/conditions")
public class TVillagerConditionsController extends BaseController
{
    @Autowired
    private ITVillagerConditionsService tVillagerConditionsService;

    /**
     * 查询村情信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:list')")
    @GetMapping("/list")
    public TableDataInfo list(TVillagerConditions tVillagerConditions)
    {
        startPage();
        List<TVillagerConditions> list = tVillagerConditionsService.selectTVillagerConditionsList(tVillagerConditions);
        return getDataTable(list);
    }

    /**
     * 导出村情信息列表
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:export')")
    @Log(title = "村情信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TVillagerConditions tVillagerConditions)
    {
        List<TVillagerConditions> list = tVillagerConditionsService.selectTVillagerConditionsList(tVillagerConditions);
        ExcelUtil<TVillagerConditions> util = new ExcelUtil<TVillagerConditions>(TVillagerConditions.class);
        return util.exportExcel(list, "村情信息数据");
    }

    /**
     * 获取村情信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tVillagerConditionsService.selectTVillagerConditionsById(id));
    }

    /**
     * 新增村情信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:add')")
    @Log(title = "村情信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TVillagerConditions tVillagerConditions)
    {
        return toAjax(tVillagerConditionsService.insertTVillagerConditions(tVillagerConditions));
    }

    /**
     * 修改村情信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:edit')")
    @Log(title = "村情信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TVillagerConditions tVillagerConditions)
    {
        return toAjax(tVillagerConditionsService.updateTVillagerConditions(tVillagerConditions));
    }

    /**
     * 删除村情信息
     */
    @PreAuthorize("@ss.hasPermi('basicdata:conditions:remove')")
    @Log(title = "村情信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tVillagerConditionsService.deleteTVillagerConditionsByIds(ids));
    }
}
